<script lang="ts" setup>
import * as orderApi from "@/api/train/order";
import OrderSimpItem from "./components/order-simp-item.vue";

const orderList = ref<OrderListResp[]>([]);

// 加载列表
const loadList = (concat: boolean = false) => {
  orderApi
    .listMemberOrder()
    .then((res) => {
      console.log(res);
      orderList.value = res.data;
    })
    .catch((err) => {
      console.log(err);
    });
};

// 下拉刷新
const refresh = ref(false);
const refreshFun = () => {
  loadList();
  refresh.value = false;
};

// 初始化列表
loadList();
</script>

<template>
  <div class="min-h-screen bg-gray-1">
    <h1 class="pt-10 pl-8 pb-2 text-3xl">我的订单</h1>
    <!-- 列表 -->
    <nut-pull-refresh v-model="refresh" @refresh="refreshFun">
      <div v-if="orderList.length" class="flex flex-col gap-3 p-3">
        <OrderSimpItem v-for="item in orderList" :key="item.id" :order="item" />
      </div>
      <nut-empty v-else image="empty" description="暂无订单" />
    </nut-pull-refresh>
  </div>
</template>
